<template>
	<view class="outBox">
		<u-navbar leftText="酒水寄存" leftIconColor="#fff" :autoBack="true" bgColor="rgba(0, 0, 0, 0.6)">
			<view class="left-slot" slot="left">
				<u-icon name="arrow-left" color="#fff"></u-icon>
				<text>{{ '酒水寄存' }}</text>
			</view>
		</u-navbar>
    <VideoBox>
      <template #content>
		<view class="content" >
			<view class="tabs">
				<view class="tab" :class="curType == 1 ? 'active' : ''" @click="changeTab(1)">
					<text>存酒</text>
				</view>
				<view class="tab" :class="curType == 2 ? 'active' : ''" @click="changeTab(2)">
					<text>取酒</text>
				</view>
			</view>
			<view class="items">
				<view class="item" :style="{
					backgroundImage:`url(${baseImgUrl}mine/bg3.png)`,
				}" v-for="item in dataList">
					<view class="left">
						<view class="top">
							<text class="name">{{item.productName}}</text>
						</view>
						<view class="bottom">
							<view class="one">
								<view class="tag">
									<text>{{curType == 1 ? '存酒' : '取酒'}}</text>
								</view>
								<text>{{curType == 1 ? item.storageEndTime : item.retrievalTime}}</text>
							</view>
<!--							<view class="one" v-if="curType == 1">-->
<!--								<view class="tag tag2">-->
<!--									<text>到期</text>-->
<!--								</view>-->
<!--								<text>{{item.createTime}}</text>-->
<!--							</view>-->
						</view>
					</view>
					<view class="right">
						<view class="top">
							<text>x{{item.productNumAndBasicUnit}}</text>
						</view>
					</view>
				</view>
			</view>

		</view>
      </template>
    </VideoBox>
	</view>
</template>

<script>
	import {
		getWXStatusHeight
	} from '@/utils/index.js'

  import {
    findRetrievalWineListForWx, findStorageWineListForWx
  } from '../../api/api'
  import VideoBox from "@/components/VideoBox/index.vue";
	export default {
    components: {VideoBox},
		data() {
			return {
				// 胶囊的宽度
				barWidth: 0,
				menuHeight: 0,
				dataList: [],
				baseImgUrl: this.$baseImgUrl,
				videoUrl: this.$videoUrl,
				curType: 1,
			}
		},
		onLoad() {
			let obj = getWXStatusHeight()
			this.barWidth = obj.barWidth + 3
			this.menuHeight = obj.menuHeight
			this.changeTab(1)
		},
		methods: {
			changeTab(type) {
				this.curType = type
				if (type == 1) {
          this.findMyBiddingList()
				} else {
          this.findMyBookingList()
				}
			},
			// 获取存酒列表
			async findMyBiddingList() {
				const res = await findStorageWineListForWx()
				if (res.code == 200) {
					this.dataList = res.data.storageWineList
				}
			},
			// 取酒列表
			async findMyBookingList() {
				const res = await findRetrievalWineListForWx()
				if (res.code == 200) {
					this.dataList = res.data.retrievalWineList
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.items {
		margin-top: 50rpx;

		.item {
			display: flex;
			justify-content: space-between;
			padding: 30rpx;
			margin-bottom: 18rpx;
      box-sizing: border-box;
			background-size: 100% 100%;

			.right {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-between;

				.top {
          margin-bottom: 34rpx;
					text {
						color: #E8EF89;
						font-size: 24rpx;
					}
				}

				.status {
					font-family: Microsoft YaHei, Microsoft YaHei;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 116rpx;
					height: 42rpx;
					background: #192A15;
					border-radius: 200rpx 200rpx 200rpx 200rpx;
					border: 2rpx solid #3ED060;

					text {
						font-weight: 400;
						font-size: 20rpx;
						color: #32F178;
					}
				}
			}

			.right2 {
				.top {
					text {
						font-weight: 500;
						font-size: 36rpx;
						color: #FFFFFF;
						line-height: 36rpx;
						text-align: right;
						font-style: normal;
					}
				}

				.status1 {
					border-color: #67E3FF;
					background: #153337;

					text {
						color: #67E3FF;
					}
				}

				.status2 {
					border-color: #414141;
					background: #282828;

					text {
						color: #414141;
					}
				}
			}

			.left {
				.top {
					display: flex;
					margin-bottom: 20rpx;

					.name {
						font-size: 32rpx;
						color: #FFFFFF;
					}

				}

				.bottom {
					font-size: 28rpx;
					color: #86909C;
					line-height: 28rpx;
					text-align: left;
					font-style: normal;

					.one {
						display: flex;
            align-items: center;
					}

					.tag {
						width: 76rpx;
						height: 40rpx;
						background: #0FC6C2;
						border-radius: 14rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						margin-right: 16rpx;

						text {
							font-weight: 400;
							font-size: 28rpx;
							color: #FFFFFF;
						}
					}

					.tag2 {
						background: #FF9A2E;
					}
				}
			}
		}
	}

	.tabs {
		display: flex;
		margin-bottom: 28rpx;
		margin-top: 40rpx;

		.tab {
			display: flex;
			justify-content: center;
			align-items: center;
			margin-right: 48rpx;

			text {
				color: #86909C;
			}
		}

		.active {
			position: relative;

			&::after {
				content: "";
				display: inline-block;
				position: absolute;
				bottom: -20rpx;
				width: 56rpx;
				height: 6rpx;
				background: #0FC6C2;
				border-radius: 4rpx;
			}

			text {
				color: #fff;
			}
		}
	}

	.content {
		position: relative;
		box-sizing: border-box;
		min-height: 100vh;
		padding: 0 32rpx;
	}

	.left-slot {
		color: #fff;
		display: flex;
		align-items: center;

		image {
			width: 40rpx;
			margin-right: 30rpx;
		}
	}

	video {
		width: 100%;
		height: 100%;
		object-fit: cover;
		/* 确保视频填充整个容器，可能会裁剪视频 */
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 0;
	}

	.outBox {}
</style>
